<HTML>
<body>
Stats<hr>
<?php
 
// Include the configuration and function files we created
require 'config.php';
 
// Establish a MySQL connection and select our database using values contained in config.php.
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);


if ($mysqli->connect_errno) {
    printf("Connect failed: %s\n", $mysqli->connect_error);
    exit();
}
echo "Crombs Stats<br>";
$query = "select count(*) as nb, year(entrytime) as y,month(entrytime) as m,day(entrytime) as d from cromb  where entrytime > TIMESTAMPADD(DAY,-2,NOW()) group by year(entrytime) desc,month(entrytime) desc,day(entrytime) desc limit 30";
if ($stmt = $mysqli->prepare($query)){
  $stmt->execute();
  $stmt->bind_result($nb,$y,$m,$d);      
  while ($stmt->fetch()){
    printf($y."-".$m."-".$d.": ".$nb."<hr>" );
   }   
   $stmt->close();
}
     
      echo "Tracker stats<br>";
      $query = "select name,userstatus,lastupdate from crombtracker";
      if ($stmt = $mysqli->prepare($query)){
        $stmt->execute();
        $stmt->bind_result($n,$s,$d);      
        while ($stmt->fetch()){
          printf($n." - ".$s." @".$d."<br>" );
        }
        echo "<hr>";
        $stmt->close();
      }

$mysqli->close();

?>
</body>
</HTML>